From 65b423eb05ba2e31c57a7f9d029f5312719366d1 Mon Sep 17 00:00:00 2001 From: Mohammed Sadiq Date: Tue, 8 May 2018 21:24:29 +0530 Subject: [PATCH] examples: Simplify counting buffer lines We do have a gtk_text_buffer_get_line_count() function to get the line count. --- examples/application10/exampleappwin.c | 11 +---------- examples/application9/exampleappwin.c | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/examples/application10/exampleappwin.c b/examples/application10/exampleappwin.c index a9311ec5a2..7b0dc46575 100644 --- a/examples/application10/exampleappwin.c +++ b/examples/application10/exampleappwin.c @@ -134,16 +134,7 @@ update_lines (ExampleAppWindow *win) view = gtk_bin_get_child (GTK_BIN (tab)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - count = 0; - - gtk_text_buffer_get_start_iter (buffer, &iter); - while (!gtk_text_iter_is_end (&iter)) - { - count++; - if (!gtk_text_iter_forward_line (&iter)) - break; - } - + count = gtk_text_buffer_get_line_count (buffer); lines = g_strdup_printf ("%d", count); gtk_label_set_text (GTK_LABEL (win->lines), lines); g_free (lines); diff --git a/examples/application9/exampleappwin.c b/examples/application9/exampleappwin.c index 50ad92a4ac..6d6ae980e9 100644 --- a/examples/application9/exampleappwin.c +++ b/examples/application9/exampleappwin.c @@ -134,16 +134,7 @@ update_lines (ExampleAppWindow *win) view = gtk_bin_get_child (GTK_BIN (tab)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - count = 0; - - gtk_text_buffer_get_start_iter (buffer, &iter); - while (!gtk_text_iter_is_end (&iter)) - { - count++; - if (!gtk_text_iter_forward_line (&iter)) - break; - } - + count = gtk_text_buffer_get_line_count (buffer); lines = g_strdup_printf ("%d", count); gtk_label_set_text (GTK_LABEL (win->lines), lines); g_free (lines); -- 2.30.2